package com.yeswater.rabbitmq_spingboot.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;
import java.util.Date;

/**
 * Author : yeswater
 */

@Slf4j
@Component
public class DeadLetterQueueListener {

    @RabbitListener(queues = "QD")
    public void receiveD(Message message) throws Exception{
        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
        log.info("当前时间: {},收到死信队列的消息: {}", new Date(), msg);
    }

    // @RabbitListener(queues = "QC")
    // public void receiveC(Message message) throws Exception{
    //     String msg = new String(message.getBody(), StandardCharsets.UTF_8);
    //     log.info("当前时间: {},收到死信队列的消息: {}", new Date(), msg);
    // }

}
